package personnel.department.dao.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.google.common.base.Preconditions;

@Entity
@Table(name="certificate")
public class Certificate implements UniqueObject {
	

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id")
	private Long id;
	
	@Column(name="series")
	private Integer series;
	
	@Column(name="number_certificate")
	private Integer numberCertificate;
	
	@Column(name="speciality")
	private String speciality;
	
	@Column(name="assignment_certificate")
	private Date assignmentCertificate;
	
	@Column(name="confirmation")
	private Date confirmation;
	
	@Column(name="first_certificate")
	private Boolean firstCertificate;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="employee_Id")
	private Employee employee;

	public Certificate(List<Object> params) {
		Preconditions.checkArgument(params.size() == 6);
		this.series = Integer.parseInt((String) params.get(0));
		this.numberCertificate = Integer.parseInt((String) params.get(1));
		this.speciality = (String) params.get(2);
		this.assignmentCertificate = (Date) params.get(3);
		this.confirmation = (Date) params.get(4);
		this.firstCertificate = (Boolean) params.get(5);
	}

	public Certificate() {}

	public Long getId() {
		return id;
	}

	public Integer getSeries() {
		return series;
	}

	public Integer getNumberCertificate() {
		return numberCertificate;
	}

	public String getSpeciality() {
		return speciality;
	}

	public Date getAssignmentCertificate() {
		return assignmentCertificate;
	}

	public Date getConfirmation() {
		return confirmation;
	}

	public Boolean getFirstCertificate() {
		return firstCertificate;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setSeries(Integer series) {
		this.series = series;
	}

	public void setNumberCertificate(Integer numberCertificate) {
		this.numberCertificate = numberCertificate;
	}

	public void setSpeciality(String speciality) {
		this.speciality = speciality;
	}

	public void setAssignmentCertificate(Date assignmentCertificate) {
		this.assignmentCertificate = assignmentCertificate;
	}

	public void setConfirmation(Date confirmation) {
		this.confirmation = confirmation;
	}

	public void setFirstCertificate(Boolean firstCertificate) {
		this.firstCertificate = firstCertificate;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	
}
